<script setup>
import { ref } from 'vue';
import { useRouter, useRoute } from 'vue-router';

const router = useRouter();
const route = useRoute();

// 获取当前子路由
const currentSubRoute = ref(route.path);

// 确保有默认子路由被选中
if (route.path === '/reports') {
  router.push('/reports/medical');
}

// 子模块导航项
const reportNavItems = [
  {
    name: '医疗数据报表',
    path: '/reports/medical',
    icon: 'DataLine'
  },
  {
    name: '医生业绩报表',
    path: '/reports/doctor',
    icon: 'UserFilled'
  },
  {
    name: 'AI 智能分析',
    path: '/reports/ai-analytics',
    icon: 'CircleCheck'
  }
];

// 导航到指定子模块
const navigateTo = (path) => {
  router.push(path);
  currentSubRoute.value = path;
};
</script>

<template>
  <div>
    <div class="page-header">
      <h1 class="page-title">数据分析</h1>
      <p class="page-subtitle">查看医院运营和医疗数据分析</p>
    </div>
    
    <div class="report-container">
      <!-- 左侧导航菜单 -->
      <div class="report-sidebar">
        <div
          v-for="item in reportNavItems"
          :key="item.path"
          class="report-nav-item"
          :class="{ active: currentSubRoute === item.path }"
          @click="navigateTo(item.path)"
        >
          <el-icon>
            <component :is="item.icon"></component>
          </el-icon>
          <span>{{ item.name }}</span>
        </div>
      </div>
      
      <!-- 右侧内容区域 -->
      <div class="report-content">
        <router-view />
      </div>
    </div>
  </div>
</template>

<style scoped>
.page-header {
  margin-bottom: 24px;
}

.page-title {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-subtitle {
  margin: 0 0 16px 0;
  color: var(--text-secondary);
}

.report-container {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--background-light);
  min-height: calc(100vh - 200px);
}

.report-sidebar {
  width: 200px;
  border-right: 1px solid var(--border-color);
  background-color: var(--background-light);
  padding: 16px 0;
}

.report-nav-item {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s;
  color: var(--text-secondary);
}

.report-nav-item:hover {
  background-color: rgba(var(--primary-color-rgb), 0.05);
  color: var(--primary-color);
}

.report-nav-item.active {
  background-color: rgba(var(--primary-color-rgb), 0.1);
  color: var(--primary-color);
  font-weight: 500;
  border-right: 3px solid var(--primary-color);
}

.report-content {
  flex: 1;
  padding: 20px;
  background-color: var(--background-default);
  overflow: auto;
}

@media (max-width: 768px) {
  .report-container {
    flex-direction: column;
  }
  
  .report-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 0;
  }
  
  .report-nav-item {
    padding: 8px 16px;
  }
}
</style> 